//
//  ZYCProfileUserHeaderInfoCell.m
//  ZDSC
//
//  Created by ZDTX on 2021/8/5.
//

#import "ZYCProfileUserHeaderInfoCell.h"
#import <UIImageView+WebCache.h>
@interface ZYCProfileUserHeaderInfoCell ()
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *statusLabel;
@property (nonatomic, strong) UIImageView *iconView;
@property (nonatomic, strong) UIImageView *arrowImageView;
@end

@implementation ZYCProfileUserHeaderInfoCell

- (void)setAvaterInfo:(NSString *)avaterInfo{
    _avaterInfo = avaterInfo;
    if (avaterInfo.length > 0) {
        _statusLabel.text = @"已录入";
        _statusLabel.textColor = HEX_RGB(@"#41B166");
    }else{
        _statusLabel.text = @"未录入";
        _statusLabel.textColor = HEX_RGB(@"#E93C06");
    }
    NSString *urlStr = [[NSString stringWithFormat:@"%@/zd-system-service%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"sdfz_url"],avaterInfo] stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
    NSURL *url = [NSURL URLWithString:urlStr];
    [_iconView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"tx-1"]];
}


- (void)setTitleString:(NSString *)titleString{
    _titleString =  titleString;
    _titleLabel.text = titleString;
    if ([titleString isEqualToString:@"账号身份:"] || [titleString isEqualToString:@"账号:"]) {
        _arrowImageView.hidden = YES;
    }
    
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.statusLabel];
        [self.contentView addSubview:self.iconView];
        [self.contentView addSubview:self.arrowImageView];
    
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(15.0f);
            make.centerY.equalTo(self.contentView);
        }];
        
        [self.statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.titleLabel.mas_right).offset(7.5);
            make.centerY.equalTo(self.contentView);
        }];
        
        [self.arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView).offset(-15.0f);
            make.centerY.equalTo(self.contentView);
            make.size.mas_equalTo(CGSizeMake(9, 16));
        }];
        
        [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.arrowImageView.mas_left).offset(-10.0f);
            make.centerY.equalTo(self.titleLabel);
            make.size.mas_equalTo(CGSizeMake(50, 50));
        }];
    }
    return self;
}

- (UIImageView *)iconView {
    if (!_iconView) {
        _iconView = [[UIImageView alloc] init];
        _iconView.layer.cornerRadius = 25.0f;
        _iconView.layer.masksToBounds = YES;
    }
    return _iconView;
}

- (UIImageView *)arrowImageView {
    if (!_arrowImageView) {
        _arrowImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"jt"]];
    }
    return _arrowImageView;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Regular", 16.0f) titleColor:HEX_RGB(@"#333333") textAlignment:ZZTextAlignmentLeft];
    }
    return _titleLabel;
}

- (UILabel *)statusLabel {
    if (!_statusLabel) {
        _statusLabel = [[UILabel alloc] init];
        _statusLabel.font = kCustomFont(@"PingFangSC-Regular", 16.0f);
        _statusLabel.textAlignment = NSTextAlignmentLeft;
    }
    return _statusLabel;
}

@end
